package com.kcht.sylyg08.service.impl;

import com.kcht.sylyg08.dao.IProductDao;
import com.kcht.sylyg08.service.IBindingProductsAndLabels;
import com.kcth.sylyg08.entity.Product;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.transaction.Transactional;
import java.util.Date;

/**
  *
  * @Package:        com.kcht.sylyg08.service.impl
  * @Description:     java类作用描述
  * @Author:         lenovo
  * @CreateDate:     2019/5/25 9:25
 */
@RequestScoped
@Transactional()
public class BindingProductsAndLabels implements IBindingProductsAndLabels {
    @EJB
    IProductDao productDao;

    @Override
    public void bindingProductsAndLabels(Product product) throws Exception {
        product.setId(null);
        product.getMaterials().stream().forEach(m->{
            m.setId(null);
            m.setProduct(product);
        });
        productDao.save(product);
    }
}
